/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Control;

import Model.Shape;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.LinkedList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;

/**
 *
 * @author PhucAnh
 */
public class View extends javax.swing.JFrame {

    /**
     * Creates new form View
     */
    public Graphics bufferGraphics = null;
    public Image bufferImage = null;
    private Color color;
    private int basicStroke;
    private Boolean isMove;
    private String typeShape;
    private boolean isEraser;
    LinkedList<Shape> myObject;
    public MyPanel jpnPaint;
    private Boolean fillColor;      //Chọn vẽ hình có đổ màu bên trong
    private Boolean colorBlock;     //Chọn tô màu

    //Cac bien xac dung cho viec mo va luu file
    private String title="";
    public static final int FILE_OPEN = 1;
    public static final int FILE_SAVE = 2;
    public View(LinkedList myObject) {
            initComponents();
            this.myObject = myObject;
            //this.setLocationRelativeTo(null);
            this.color = Color.BLACK;
            this.basicStroke = 5;
            this.isMove = false;
            this.typeShape = "CURVE";
            this.fillColor = false;
            this.colorBlock = false;
            this.isEraser = false;
            jpnPaint = new MyPanel(this.myObject,bufferImage);
            jpnPaint.setSize(1320, 550);
            jpnPaint.setLocation(20, 140);
            Toolkit kit = Toolkit.getDefaultToolkit();
            Dimension dim = kit.getScreenSize();
            this.setSize(dim);
            this.add(jpnPaint);
    }
    public int getHeightPaint()
    {
        return jpnPaint.getHeight();
    }
    
    public int getWidthPaint()
    {
        return jpnPaint.getWidth();
    }
    public MyPanel getPaint()
    {
        return jpnPaint;
    }
    public Boolean getColorBlock() {
        return colorBlock;
    }

    public void setColorBlock(Boolean colorBlock) {
        this.colorBlock = colorBlock;
    }

    public Color getColor() {
        return color;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public int getBasicStroke() {
        return basicStroke;
    }

    public void setBasicStroke(int basicStroke) {
        this.basicStroke = basicStroke;
    }

    public Boolean getIsMove() {
        return isMove;
    }

    public void setIsMove(Boolean isMove) {
        this.isMove = isMove;
    }

    public String getTypeShape() {
        return typeShape;
    }

    public void setTypeShape(String typeShape) {
        this.typeShape = typeShape;
    }

    public Boolean getFillColor() {
        return fillColor;
    }

    public void setFillColor(Boolean fillColor) {
        this.fillColor = fillColor;
    }

    public boolean isIsEraser() {
        return isEraser;
    }

    public void setIsEraser(boolean isEraser) {
        this.isEraser = isEraser;
    }

    public void addViewMouseListener(MouseAdapter al) {
        jpnPaint.addMouseListener(al);
    }

    public void addViewMouseMotionListener(MouseAdapter al) {
        jpnPaint.addMouseMotionListener(al);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btngShape = new javax.swing.ButtonGroup();
        btngColor = new javax.swing.ButtonGroup();
        lbLocation = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jpnShape = new javax.swing.JPanel();
        btnOval = new javax.swing.JToggleButton();
        btnRectangle = new javax.swing.JToggleButton();
        btnLine = new javax.swing.JToggleButton();
        btnHexagon = new javax.swing.JToggleButton();
        btnStar = new javax.swing.JToggleButton();
        btnHeart = new javax.swing.JToggleButton();
        btnDiamond = new javax.swing.JToggleButton();
        btnTriangle = new javax.swing.JToggleButton();
        jpnMode = new javax.swing.JPanel();
        btnEraser = new javax.swing.JToggleButton();
        btnColorBlock = new javax.swing.JToggleButton();
        btnPencil = new javax.swing.JToggleButton();
        jpnColor = new javax.swing.JPanel();
        btnBlack = new javax.swing.JToggleButton();
        btnWhite = new javax.swing.JToggleButton();
        btnGray = new javax.swing.JToggleButton();
        btnIndigo = new javax.swing.JToggleButton();
        btnRed = new javax.swing.JToggleButton();
        btnYellow = new javax.swing.JToggleButton();
        btnPurple = new javax.swing.JToggleButton();
        btnGreen = new javax.swing.JToggleButton();
        btnRose = new javax.swing.JToggleButton();
        btnOrange = new javax.swing.JToggleButton();
        btnLime = new javax.swing.JToggleButton();
        btnBrown = new javax.swing.JToggleButton();
        btnColorChoose = new javax.swing.JToggleButton();
        btnIsFill = new javax.swing.JToggleButton();
        jslBasicStroke = new javax.swing.JSlider();
        jPanel3 = new javax.swing.JPanel();
        btnUndo = new javax.swing.JButton();
        btnRedo = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        miNew = new javax.swing.JMenuItem();
        miOpen = new javax.swing.JMenuItem();
        miSave = new javax.swing.JMenuItem();
        miSaveAs = new javax.swing.JMenuItem();
        miPrint = new javax.swing.JMenuItem();
        miClose = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("BK Paint");
        setBackground(new java.awt.Color(0, 0, 255));
        setResizable(false);

        lbLocation.setText("jLabel1");

        jpnShape.setBackground(new java.awt.Color(204, 204, 204));

        btnOval.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnOval);
        btnOval.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_oval.png"))); // NOI18N
        btnOval.setBorder(null);
        btnOval.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOvalActionPerformed(evt);
            }
        });

        btnRectangle.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnRectangle);
        btnRectangle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_rectangular.png"))); // NOI18N
        btnRectangle.setBorder(null);
        btnRectangle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRectangleActionPerformed(evt);
            }
        });

        btnLine.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnLine);
        btnLine.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_line.png"))); // NOI18N
        btnLine.setBorder(null);
        btnLine.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLineActionPerformed(evt);
            }
        });

        btnHexagon.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnHexagon);
        btnHexagon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_hexagon.png"))); // NOI18N
        btnHexagon.setBorder(null);
        btnHexagon.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHexagonActionPerformed(evt);
            }
        });

        btnStar.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnStar);
        btnStar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_star.png"))); // NOI18N
        btnStar.setBorder(null);
        btnStar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnStarActionPerformed(evt);
            }
        });

        btnHeart.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnHeart);
        btnHeart.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_heart.png"))); // NOI18N
        btnHeart.setBorder(null);
        btnHeart.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnHeartActionPerformed(evt);
            }
        });

        btnDiamond.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnDiamond);
        btnDiamond.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_diamond.png"))); // NOI18N
        btnDiamond.setBorder(null);
        btnDiamond.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDiamondActionPerformed(evt);
            }
        });

        btnTriangle.setBackground(new java.awt.Color(0, 0, 255));
        btngShape.add(btnTriangle);
        btnTriangle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/s_triangle.png"))); // NOI18N
        btnTriangle.setBorder(null);
        btnTriangle.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTriangleActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpnShapeLayout = new javax.swing.GroupLayout(jpnShape);
        jpnShape.setLayout(jpnShapeLayout);
        jpnShapeLayout.setHorizontalGroup(
            jpnShapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnShapeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnShapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnShapeLayout.createSequentialGroup()
                        .addComponent(btnLine, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(btnOval, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnRectangle, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnHexagon, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnShapeLayout.createSequentialGroup()
                        .addComponent(btnStar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnHeart, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnDiamond, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(btnTriangle, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpnShapeLayout.setVerticalGroup(
            jpnShapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnShapeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnShapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnRectangle, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnOval, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnLine, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHexagon, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpnShapeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnStar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnHeart, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnDiamond, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnTriangle, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jpnMode.setBackground(new java.awt.Color(204, 204, 204));

        btnEraser.setBackground(new java.awt.Color(255, 255, 255));
        btngShape.add(btnEraser);
        btnEraser.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/cleaner.png"))); // NOI18N
        btnEraser.setBorder(null);
        btnEraser.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/cleaner2.png"))); // NOI18N
        btnEraser.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/cleaner3.png"))); // NOI18N
        btnEraser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEraserActionPerformed(evt);
            }
        });

        btngShape.add(btnColorBlock);
        btnColorBlock.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/fcolor.png"))); // NOI18N
        btnColorBlock.setBorder(null);
        btnColorBlock.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/fcolor1.png"))); // NOI18N
        btnColorBlock.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/fcolor2.png"))); // NOI18N
        btnColorBlock.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnColorBlockActionPerformed(evt);
            }
        });

        btngShape.add(btnPencil);
        btnPencil.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/pencil4.png"))); // NOI18N
        btnPencil.setSelected(true);
        btnPencil.setBorder(null);
        btnPencil.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/pencil1.png"))); // NOI18N
        btnPencil.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/pencil2.png"))); // NOI18N
        btnPencil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPencilActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpnModeLayout = new javax.swing.GroupLayout(jpnMode);
        jpnMode.setLayout(jpnModeLayout);
        jpnModeLayout.setHorizontalGroup(
            jpnModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnModeLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btnEraser, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnPencil, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnColorBlock, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jpnModeLayout.setVerticalGroup(
            jpnModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpnModeLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpnModeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnPencil, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnEraser, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnColorBlock, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jpnColor.setBackground(new java.awt.Color(204, 204, 204));

        btngColor.add(btnBlack);
        btnBlack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_black.png"))); // NOI18N
        btnBlack.setSelected(true);
        btnBlack.setBorder(new javax.swing.border.MatteBorder(null));
        btnBlack.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_black1.png"))); // NOI18N
        btnBlack.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_black1.png"))); // NOI18N
        btnBlack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBlackActionPerformed(evt);
            }
        });

        btngColor.add(btnWhite);
        btnWhite.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_while.png"))); // NOI18N
        btnWhite.setBorder(new javax.swing.border.MatteBorder(null));
        btnWhite.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_while.png"))); // NOI18N
        btnWhite.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_while.png"))); // NOI18N
        btnWhite.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnWhiteActionPerformed(evt);
            }
        });

        btngColor.add(btnGray);
        btnGray.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_gray.png"))); // NOI18N
        btnGray.setBorder(new javax.swing.border.MatteBorder(null));
        btnGray.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_gray1.png"))); // NOI18N
        btnGray.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_gray1.png"))); // NOI18N
        btnGray.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGrayActionPerformed(evt);
            }
        });

        btngColor.add(btnIndigo);
        btnIndigo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_indigo.png"))); // NOI18N
        btnIndigo.setBorder(new javax.swing.border.MatteBorder(null));
        btnIndigo.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_indigo1.png"))); // NOI18N
        btnIndigo.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_indigo1.png"))); // NOI18N
        btnIndigo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIndigoActionPerformed(evt);
            }
        });

        btngColor.add(btnRed);
        btnRed.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_red.png"))); // NOI18N
        btnRed.setBorder(new javax.swing.border.MatteBorder(null));
        btnRed.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_red1.png"))); // NOI18N
        btnRed.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_red1.png"))); // NOI18N
        btnRed.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRedActionPerformed(evt);
            }
        });

        btngColor.add(btnYellow);
        btnYellow.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_yellow.png"))); // NOI18N
        btnYellow.setBorder(new javax.swing.border.MatteBorder(null));
        btnYellow.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_yellow1.png"))); // NOI18N
        btnYellow.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_yellow1.png"))); // NOI18N
        btnYellow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnYellowActionPerformed(evt);
            }
        });

        btngColor.add(btnPurple);
        btnPurple.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_purple.png"))); // NOI18N
        btnPurple.setBorder(new javax.swing.border.MatteBorder(null));
        btnPurple.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_purple1.png"))); // NOI18N
        btnPurple.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_purple1.png"))); // NOI18N
        btnPurple.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPurpleActionPerformed(evt);
            }
        });

        btngColor.add(btnGreen);
        btnGreen.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_green.png"))); // NOI18N
        btnGreen.setBorder(new javax.swing.border.MatteBorder(null));
        btnGreen.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_green1.png"))); // NOI18N
        btnGreen.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_green1.png"))); // NOI18N
        btnGreen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnGreenActionPerformed(evt);
            }
        });

        btngColor.add(btnRose);
        btnRose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_rose.png"))); // NOI18N
        btnRose.setBorder(new javax.swing.border.MatteBorder(null));
        btnRose.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_rose1.png"))); // NOI18N
        btnRose.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_rose1.png"))); // NOI18N
        btnRose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRoseActionPerformed(evt);
            }
        });

        btngColor.add(btnOrange);
        btnOrange.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_orange.png"))); // NOI18N
        btnOrange.setBorder(new javax.swing.border.MatteBorder(null));
        btnOrange.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_orange1.png"))); // NOI18N
        btnOrange.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_orange1.png"))); // NOI18N
        btnOrange.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOrangeActionPerformed(evt);
            }
        });

        btngColor.add(btnLime);
        btnLime.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_lime.png"))); // NOI18N
        btnLime.setBorder(new javax.swing.border.MatteBorder(null));
        btnLime.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_lime1.png"))); // NOI18N
        btnLime.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_lime1.png"))); // NOI18N
        btnLime.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimeActionPerformed(evt);
            }
        });

        btngColor.add(btnBrown);
        btnBrown.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_brown.png"))); // NOI18N
        btnBrown.setBorder(new javax.swing.border.MatteBorder(null));
        btnBrown.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_brown1.png"))); // NOI18N
        btnBrown.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/c_brown1.png"))); // NOI18N
        btnBrown.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnBrownActionPerformed(evt);
            }
        });

        btngColor.add(btnColorChoose);
        btnColorChoose.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/colorchoose.png"))); // NOI18N
        btnColorChoose.setBorder(new javax.swing.border.MatteBorder(null));
        btnColorChoose.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/colorchoose1.png"))); // NOI18N
        btnColorChoose.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/colorchoose1.png"))); // NOI18N
        btnColorChoose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnColorChooseActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jpnColorLayout = new javax.swing.GroupLayout(jpnColor);
        jpnColor.setLayout(jpnColorLayout);
        jpnColorLayout.setHorizontalGroup(
            jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnColorLayout.createSequentialGroup()
                .addGroup(jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpnColorLayout.createSequentialGroup()
                        .addComponent(btnBlack, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnGray, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRed, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnYellow, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnGreen, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnOrange, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jpnColorLayout.createSequentialGroup()
                        .addComponent(btnWhite, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnIndigo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnPurple, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnBrown, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnRose, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnLime, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(btnColorChoose, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jpnColorLayout.setVerticalGroup(
            jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpnColorLayout.createSequentialGroup()
                .addGroup(jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnColorChoose, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jpnColorLayout.createSequentialGroup()
                        .addGroup(jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnBlack, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnGray, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnRed, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnYellow, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnGreen, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnOrange, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpnColorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(btnWhite, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnIndigo, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnPurple, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnBrown, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnRose, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnLime, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(5, 5, 5))
        );

        btnIsFill.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/isFill1.png"))); // NOI18N
        btnIsFill.setBorder(new javax.swing.border.MatteBorder(null));
        btnIsFill.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/isFill.png"))); // NOI18N
        btnIsFill.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/isFill2.png"))); // NOI18N
        btnIsFill.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIsFillActionPerformed(evt);
            }
        });

        jslBasicStroke.setPaintTicks(true);
        jslBasicStroke.setBorder(new javax.swing.border.MatteBorder(null));
        jslBasicStroke.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                jslBasicStrokeStateChanged(evt);
            }
        });

        btnUndo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/undo_1.png"))); // NOI18N
        btnUndo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUndoActionPerformed(evt);
            }
        });

        btnRedo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/Image/redo_1.png"))); // NOI18N

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnUndo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnRedo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(26, 26, 26))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(btnRedo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnUndo, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jButton1.setText("Play");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jpnMode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, 109, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jpnShape, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnIsFill, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jslBasicStroke, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jpnColor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(52, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jpnShape, javax.swing.GroupLayout.DEFAULT_SIZE, 0, Short.MAX_VALUE)
                        .addComponent(jpnMode, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jslBasicStroke, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnIsFill, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jpnColor, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jMenu1.setText("  File  ");
        jMenu1.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N

        miNew.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        miNew.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miNew.setText("New");
        jMenu1.add(miNew);

        miOpen.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        miOpen.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miOpen.setText("Open");
        miOpen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miOpenActionPerformed(evt);
            }
        });
        jMenu1.add(miOpen);

        miSave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        miSave.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miSave.setText("Save");
        miSave.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miSaveActionPerformed(evt);
            }
        });
        jMenu1.add(miSave);

        miSaveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        miSaveAs.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miSaveAs.setText("Save as");
        miSaveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miSaveAsActionPerformed(evt);
            }
        });
        jMenu1.add(miSaveAs);

        miPrint.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        miPrint.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miPrint.setText("Print");
        miPrint.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                miPrintActionPerformed(evt);
            }
        });
        jMenu1.add(miPrint);

        miClose.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        miClose.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        miClose.setText("Close");
        jMenu1.add(miClose);

        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenu2.setFont(new java.awt.Font("Tempus Sans ITC", 1, 14)); // NOI18N
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(lbLocation, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 553, Short.MAX_VALUE)
                .addComponent(lbLocation))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOvalActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOvalActionPerformed
        // TODO add your handling code here:
        if (btnOval.isSelected()) {
            this.setTypeShape("OVAL");
        }

    }//GEN-LAST:event_btnOvalActionPerformed

    private void btnLineActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLineActionPerformed
        // TODO add your handling code here:
        if (btnLine.isSelected()) {
            this.setTypeShape("LINE");
        }

    }//GEN-LAST:event_btnLineActionPerformed

    private void btnHexagonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHexagonActionPerformed
        // TODO add your handling code here:
        if (btnHexagon.isSelected()) {
            this.setTypeShape("HEXAGON");
        }
    }//GEN-LAST:event_btnHexagonActionPerformed

    private void btnTriangleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTriangleActionPerformed
        // TODO add your handling code here:
        if (btnTriangle.isSelected()) {
            this.setTypeShape("TRIANGLE");
        }
    }//GEN-LAST:event_btnTriangleActionPerformed

    private void btnStarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnStarActionPerformed
        // TODO add your handling code here:
        if (btnStar.isSelected()) {
            this.setTypeShape("STAR");
        }
    }//GEN-LAST:event_btnStarActionPerformed

    private void btnHeartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnHeartActionPerformed
        // TODO add your handling code here:
        if (btnHeart.isSelected()) {
            this.setTypeShape("HEART");
        }
    }//GEN-LAST:event_btnHeartActionPerformed

    private void btnDiamondActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDiamondActionPerformed
        // TODO add your handling code here:
        if (btnDiamond.isSelected()) {
            this.setTypeShape("DIAMOND");
        }
    }//GEN-LAST:event_btnDiamondActionPerformed

    private void btnPencilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPencilActionPerformed
        // TODO add your handling code here:
        if (btnPencil.isSelected()) {
            this.setTypeShape("CURVE");
        }
    }//GEN-LAST:event_btnPencilActionPerformed

    private void btnEraserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEraserActionPerformed
        // TODO add your handling code here:
        if (btnEraser.isSelected()) {
            this.setIsEraser(true);
        } else {
            this.setIsEraser(false);
        }
    }//GEN-LAST:event_btnEraserActionPerformed

    private void btnColorBlockActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnColorBlockActionPerformed
        // TODO add your handling code here:
        if (btnColorBlock.isSelected()) {
            this.setColorBlock(true);
        } else {
            this.setColorBlock(false);
        }
    }//GEN-LAST:event_btnColorBlockActionPerformed

    private void btnBlackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBlackActionPerformed
        // TODO add your handling code here:
        if (btnBlack.isSelected()) {
            this.setColor(Color.BLACK);
        }
    }//GEN-LAST:event_btnBlackActionPerformed

    private void btnGrayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGrayActionPerformed
        // TODO add your handling code here:
        if (btnGray.isSelected()) {
            this.setColor(Color.GRAY);
        }
    }//GEN-LAST:event_btnGrayActionPerformed

    private void btnRedActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRedActionPerformed
        // TODO add your handling code here:
        if (btnRed.isSelected()) {
            this.setColor(Color.RED);
        }
    }//GEN-LAST:event_btnRedActionPerformed

    private void btnYellowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnYellowActionPerformed
        // TODO add your handling code here:
        if (btnYellow.isSelected()) {
            this.setColor(Color.YELLOW);
        }
    }//GEN-LAST:event_btnYellowActionPerformed

    private void btnGreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGreenActionPerformed
        // TODO add your handling code here:
        if (btnGreen.isSelected()) {
            this.setColor(Color.GREEN);
        }
    }//GEN-LAST:event_btnGreenActionPerformed

    private void btnOrangeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOrangeActionPerformed
        // TODO add your handling code here:
        if (btnOrange.isSelected()) {
            this.setColor(Color.ORANGE);
        }
    }//GEN-LAST:event_btnOrangeActionPerformed

    private void btnWhiteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnWhiteActionPerformed
        // TODO add your handling code here:
        if (btnWhite.isSelected()) {
            this.setColor(Color.WHITE);
        }
    }//GEN-LAST:event_btnWhiteActionPerformed

    private void btnIndigoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIndigoActionPerformed
        // TODO add your handling code here:
        if (btnIndigo.isSelected()) {
            this.setColor(Color.blue);
        }
    }//GEN-LAST:event_btnIndigoActionPerformed

    private void btnPurpleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPurpleActionPerformed
        // TODO add your handling code here:
        if (btnPurple.isSelected()) {
            this.setColor(Color.CYAN);
        }
    }//GEN-LAST:event_btnPurpleActionPerformed

    private void btnBrownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnBrownActionPerformed
        // TODO add your handling code here:
        if (btnBrown.isSelected()) {
            this.setColor(Color.DARK_GRAY);
        }
    }//GEN-LAST:event_btnBrownActionPerformed

    private void btnRoseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRoseActionPerformed
        // TODO add your handling code here:
        if (btnRose.isSelected()) {
            this.setColor(Color.pink);
        }
    }//GEN-LAST:event_btnRoseActionPerformed

    private void btnLimeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimeActionPerformed
        // TODO add your handling code here:
        if (btnLime.isSelected()) {
            this.setColor(Color.magenta);
        }
    }//GEN-LAST:event_btnLimeActionPerformed

    private void btnColorChooseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnColorChooseActionPerformed
        // TODO add your handling code here:
        ColorChoose clcs = new ColorChoose(this, true);
        clcs.setVisible(true);
        if (clcs.getColor() != null) {
            this.setColor(clcs.getColor());
        }

    }//GEN-LAST:event_btnColorChooseActionPerformed

    private void jslBasicStrokeStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_jslBasicStrokeStateChanged
        // TODO add your handling code here:
        this.setBasicStroke(jslBasicStroke.getValue() / 10);
    }//GEN-LAST:event_jslBasicStrokeStateChanged

    private void btnIsFillActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIsFillActionPerformed
        // TODO add your handling code here:
        if (btnIsFill.isSelected()) {
            if (btnPencil.isSelected() || btnColorBlock.isSelected() || btnEraser.isSelected()) {
                btnOval.setSelected(true);
                this.setTypeShape("OVAL");
            }
            this.setFillColor(true);
        } else {
            this.setFillColor(false);
        }
    }//GEN-LAST:event_btnIsFillActionPerformed

    private void btnRectangleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRectangleActionPerformed
        // TODO add your handling code here:
        if (btnRectangle.isSelected()) {
            this.setTypeShape("RECTANGULAR");
        }

    }//GEN-LAST:event_btnRectangleActionPerformed

    private void btnUndoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUndoActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_btnUndoActionPerformed

    private void miSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miSaveActionPerformed
        // TODO add your handling code here:
        title ="Save a file";
        operateFile(title, FILE_SAVE);
    }//GEN-LAST:event_miSaveActionPerformed

    private void miSaveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miSaveAsActionPerformed
        // TODO add your handling code here:
        title ="Save a file";
        operateFile(title, FILE_SAVE);
    }//GEN-LAST:event_miSaveAsActionPerformed

    private void miPrintActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miPrintActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_miPrintActionPerformed

    private void miOpenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_miOpenActionPerformed
        // TODO add your handling code here:
        title = "Open a file";
        operateFile(title, FILE_OPEN);
    }//GEN-LAST:event_miOpenActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // TODO add your handling code here:
        PlayBack pb = new PlayBack(this, true, myObject);
        pb.setVisible(true);
    }//GEN-LAST:event_jButton1ActionPerformed
    
    private void operateFile(String title,int type)
    {
        JFileChooser file = new JFileChooser();
        file.setToolTipText(title);
        int choose = -1;
        switch(type)
        {
            case FILE_OPEN:
                choose=file.showOpenDialog(null);
                break;
            case FILE_SAVE:
                choose=file.showSaveDialog(null);
                break;
        }
        if(choose==JFileChooser.APPROVE_OPTION) {
            switch(type)
            {
                case FILE_OPEN:
                    File selectedFile = file.getSelectedFile();
                    System.out.println("Path:"+selectedFile.getPath());
                    System.out.println("Name:"+selectedFile.getName());
            try {
                FileInputStream fis = new FileInputStream(selectedFile);
                DataInputStream dis = new DataInputStream(fis);
                byte[] data = new byte[dis.available()];
                dis.readFully(data);

                dis.close();
            } catch (IOException ex) {
                Logger.getLogger(View.class.getName()).log(Level.SEVERE, null, ex);
            }
                    break;
                case FILE_SAVE:

                    break;
            }
        }
        
    }
    public void addRedoClick(ActionListener evt) {
        btnUndo.addActionListener(evt);
    }

    public void setToaDo(int x, int y) {
        lbLocation.setText(x + "x" + y);
    }
    /**
     * @param args the command line arguments
     */
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JToggleButton btnBlack;
    private javax.swing.JToggleButton btnBrown;
    private javax.swing.JToggleButton btnColorBlock;
    private javax.swing.JToggleButton btnColorChoose;
    private javax.swing.JToggleButton btnDiamond;
    private javax.swing.JToggleButton btnEraser;
    private javax.swing.JToggleButton btnGray;
    private javax.swing.JToggleButton btnGreen;
    private javax.swing.JToggleButton btnHeart;
    private javax.swing.JToggleButton btnHexagon;
    private javax.swing.JToggleButton btnIndigo;
    private javax.swing.JToggleButton btnIsFill;
    private javax.swing.JToggleButton btnLime;
    private javax.swing.JToggleButton btnLine;
    private javax.swing.JToggleButton btnOrange;
    private javax.swing.JToggleButton btnOval;
    private javax.swing.JToggleButton btnPencil;
    private javax.swing.JToggleButton btnPurple;
    private javax.swing.JToggleButton btnRectangle;
    private javax.swing.JToggleButton btnRed;
    private javax.swing.JButton btnRedo;
    private javax.swing.JToggleButton btnRose;
    private javax.swing.JToggleButton btnStar;
    private javax.swing.JToggleButton btnTriangle;
    private javax.swing.JButton btnUndo;
    private javax.swing.JToggleButton btnWhite;
    private javax.swing.JToggleButton btnYellow;
    private javax.swing.ButtonGroup btngColor;
    private javax.swing.ButtonGroup btngShape;
    private javax.swing.JButton jButton1;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jpnColor;
    private javax.swing.JPanel jpnMode;
    private javax.swing.JPanel jpnShape;
    private javax.swing.JSlider jslBasicStroke;
    private javax.swing.JLabel lbLocation;
    private javax.swing.JMenuItem miClose;
    private javax.swing.JMenuItem miNew;
    private javax.swing.JMenuItem miOpen;
    private javax.swing.JMenuItem miPrint;
    private javax.swing.JMenuItem miSave;
    private javax.swing.JMenuItem miSaveAs;
    // End of variables declaration//GEN-END:variables
}
